package com.monter.carlo.poker.domain;

import java.io.Serializable;

public class Result<T> implements Serializable {

	private static final long serialVersionUID = -9115248885325884080L;
	private boolean success = true;
	private String rstCode;
	private String rstInfo;
	private T resultData;

	public Result(String rstCode) {
		this.setRstCode(ResultCode.getResultCode(rstCode).getCode());
		this.setRstInfo(ResultCode.getResultCode(rstCode).getDesc());
	}

	public Result(boolean success) {
		this.setSuccess(success);
	}

	public Result(boolean success, String rstCode) {
		this.setSuccess(success);
		this.setRstCode(ResultCode.getResultCode(rstCode).getCode());
		this.setRstInfo(ResultCode.getResultCode(rstCode).getDesc());
	}

	public String getRstCode() {
		return rstCode;
	}

	public void setRstCode(String rstCode) {
		this.rstCode = rstCode;
	}

	public String getRstInfo() {
		return rstInfo;
	}

	public void setRstInfo(String rstInfo) {
		this.rstInfo = rstInfo;
	}

	public boolean isSuccess() {
		return success;
	}

	public boolean isFailed() {
		return !isSuccess();
	}

	public Result<T> setSuccess(boolean success) {
		this.success = success;
		return this;
	}

	public T getResultData() {
		return resultData;
	}

	public void setResultData(T resultData) {
		this.resultData = resultData;
	}

}
